<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			function getCurrentTime(){
				// 2017-12-12 14:57:32 返回格式
				var date 	= new Date();			// 日期对象
				var year 	= date.getFullYear();	// 年份
				var month 	= ('0' + date.getMonth() + 1).substr(-2);	// 月份
				var day 	= ('0' + date.getDate()).substr(-2);;		// 日期
				var hours 	= ('0' + date.getHours()).substr(-2);;		// 小时
				var minutes = ('0' + date.getMinutes()).substr(-2);;	// 分钟
				var seconds = ('0' + date.getSeconds()).substr(-2);	// 秒钟 6 == 016
				return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
			}
			console.log(getCurrentTime());
			var func = function(){
				document.body.innerText = getCurrentTime();
			}
			setInterval(func,1000);
		</script>
	</body>
</html>